package com.overoid.diary.ui.day.edit;

import com.overoid.diary.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;


public class DayEditViewBottom01Activity extends Activity{
	
	// categoryId
	 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);	
		
		setContentView(R.layout.day_edit_view_bottom01);
		
		
		final ImageButton imgBtnCatetory01 =  (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory01);
		imgBtnCatetory01.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				setCategoyImg(1);
				
			}
		});
		final ImageButton imgBtnCatetory02 =  (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory02);
		imgBtnCatetory02.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				setCategoyImg(2);
				
			}
		});
		
		final ImageButton imgBtnCatetory03 =  (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory03);
		imgBtnCatetory03.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				setCategoyImg(3);
				
			}
		});
		
		final ImageButton imgBtnCatetory04 =  (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory04);
		imgBtnCatetory04.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				setCategoyImg(4);				
			}
		});
		
	}
	
	public void setCategoyImg(int selectPosition){
		
		ImageButton currentImg = null; 
		ImageButton selectImg = null;
		DayEditActivity act = (DayEditActivity)getParent();
		if(act.categotyID != selectPosition){
			
			if(act.categotyID ==1 ){
				currentImg = (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory01);
			}else if(act.categotyID ==2 ){
				currentImg = (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory02);
			}else if(act.categotyID ==3 ){
				currentImg = (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory03);
			}else if(act.categotyID ==4 ){
				currentImg = (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory04);
			}
			
			if(selectPosition ==1 ){
				selectImg = (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory01);
			}else if(selectPosition ==2 ){
				selectImg = (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory02);
			}else if(selectPosition ==3 ){
				selectImg = (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory03);
			}else if(selectPosition ==4 ){
				selectImg = (ImageButton)findViewById(R.id.dayEditImgBtnBottomTab01Catetory04);
			}
			
			
			
			if(act.categotyID != 0) currentImg.setBackgroundDrawable(getResources().getDrawable(R.drawable.dayedit_picture_shape));
			
			selectImg.setBackgroundDrawable(getResources().getDrawable(R.drawable.dayedit_picture_shape_select));
			
			act.categotyID = selectPosition;
		}
		
	}
}